package com.softroad.help.app.ui;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.GridView;

import com.softroad.help.app.AppManager;
import com.softroad.help.app.R;
import com.softroad.help.app.adapter.MainAdapter;
import com.softroad.help.app.login.LoginActivity;

public class MainActivity extends BaseActivity {

	private GridView grideview;

	public static void startActivity(Context context) {
		context.startActivity(new Intent(context, MainActivity.class));
	}

	@Override
	public int bindLayout() {
		// TODO Auto-generated method stub
		return R.layout.main;
	}

	@Override
	public void initView(View view) {
		action_back.setVisibility(View.GONE);
		grideview = $(R.id.grideview);
		MainAdapter adapter = new MainAdapter(this, new OnClick() {

			@Override
			public void onClick(int position) {
				switch (position) {
				case 0:
					SubmitPhotoActivity.startActivity(getContext());
					break;
				case 1:
					ReportListActivity.startActivity(getContext());
					break;
				case 2:

					break;
				case 3:

					break;
				case 4:

					break;
				case 5:
					mApplication.setLogin(false);
					if (mApplication.isReadDataCache("user")) {
						mApplication.deleteObject("user");
					}
					LoginActivity.startActivity(getContext());
					AppManager.getAppManager().finishActivity();
					break;

				default:
					break;
				}
			}
		});
		grideview.setAdapter(adapter);
	}

	public interface OnClick {
		public void onClick(int position);
	}

	@Override
	public void initData(Context mContext) {

	}

	@Override
	public void initListener() {

	}

	@Override
	public void resume() {

	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

}
